//
//  DbInisializerTester.m
//  DataCollector
//
//  Created by jiro on 12/07/12.
//  Copyright 2012 jiro music. All rights reserved.
//

#import "DbInisializerTester.h"

#import "../../Commons.h"

@implementation DbInisializerTester

+ (void) testAll
{
	[ DbInisializerTester testCalcMaWithValues ];
}

+ (void) testCalcMaWithValues000
{
	NSMutableArray* values = [ NSMutableArray array ];
	int averageLength = 3;
	
	[ values addObject: [ NSNumber numberWithDouble: 0 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 1 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 2 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 3 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 4 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 5 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 6 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 7 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 8 ] ];
	[ values addObject: [ NSNumber numberWithDouble: 9 ] ];

	NSArray* mas = [ StaticsUtility calcMaWithValues: values andAverageLength: averageLength ];
	AssertEqual( [ mas count ], 8, @"%d" ); 
	for ( int i = 0; i < 8; i++ )
	{
		AssertEqual( [ [ mas objectAtIndex: i ] doubleValue ], i + 1, @"%f" );
	}
}

+ (void) testCalcMaWithValues
{
	[ DbInisializerTester testCalcMaWithValues000 ];
}

@end
